//function readint16_byDec_fromDefine(i_str)
//{
//    return $sqlMcRecorder.qml_getRecordVal_toint16(
//                        $sqlMcDefine.qml_queryTableOnce('SELECT dec FROM mc_define WHERE define='+'\''+i_str+'\''))
//}

function readWhichChannelRunning()
{
    if($sqlMcRecorder.qml_getBitBool("A套","调节器状态","本通道运行"))
        return "A套";
    if($sqlMcRecorder.qml_getBitBool("B套","调节器状态","本通道运行"))
        return "B套";
//    if($sqlMcRecorder.qml_getBitBool("C套","调节器状态","本通道运行"))
//        return "C套";
    console.log("no channel running")
    return "A套";
}

function readRegSingalLimit(sqlName)
{
    var t_var = $sqlMcRecorder.qml_getRegulatorVal_bystr_toint16(sqlName)
    var min = $sqlMcDefine.qml_queryTableOnce("SELECT min FROM reg_define WHERE define='"+sqlName+"'")
    var max = $sqlMcDefine.qml_queryTableOnce("SELECT max FROM reg_define WHERE define='"+sqlName+"'")
    var point = $sqlMcDefine.qml_queryTableOnce("SELECT pointLocation FROM reg_define WHERE define='"+sqlName+"'")

    if(t_var >= min && t_var <= max)
        return String((t_var/Math.pow(10, point)).toFixed(point))
    else
        return "???"
}


function writeRegSingalLimit(text, sqlName)
{
    if(text === "???") return
    var min = $sqlMcDefine.qml_queryTableOnce("SELECT min FROM reg_define WHERE define='"+sqlName+"'")
    var max = $sqlMcDefine.qml_queryTableOnce("SELECT max FROM reg_define WHERE define='"+sqlName+"'")
    var point = $sqlMcDefine.qml_queryTableOnce("SELECT pointLocation FROM reg_define WHERE define='"+sqlName+"'")

    var t_var = Number(text)*Math.pow(10, point)
    if(t_var >= min && t_var <= max)
        $modbusInterface.sl_modbusWriteData($sqlMcDefine.qml_queryTableRegDef(sqlName), t_var.toFixed(0))
}

function readRegScope(sqlName)
{
    var min = $sqlMcDefine.qml_queryTableOnce("SELECT min FROM reg_define WHERE define='"+sqlName+"'")
    var max = $sqlMcDefine.qml_queryTableOnce("SELECT max FROM reg_define WHERE define='"+sqlName+"'")
    var point = $sqlMcDefine.qml_queryTableOnce("SELECT pointLocation FROM reg_define WHERE define='"+sqlName+"'")
    return Number(min/Math.pow(10, point)).toFixed(point)+"~"+Number(max/Math.pow(10, point)).toFixed(point)
}
